package indi.zjh.dp.orm;

import java.lang.reflect.Method;

import indi.zjh.dp.db.Session;
import indi.zjh.dp.util.SerializeUtil;


public class MethodFactory {
	public static Method BusinessSetIdMethod = null;
	public static Method BusinessIsModifiedMethod = null;
	public static Method BusinessUpdateWriteTimestampMethod = null;
	public static Method BusinessGetIdsMethod = null;
	public static Method BusinessSaveIdMethod = null;
	public static Method BusinessMarkMethod = null;
	public static Method BusinessIsContainedMethod = null;
	public static Method BusinessIncrVersionMethod = null;
	public static Method BusinessSaveVersionMethod = null;
	
	//public static Method SessionGetMethod = null;
	
	public static Method RelationGetIdSetMethod = null;
	public static void init()
	{
		try {
			System.out.println("初始化MethodFactory");
			

//			SerializeUtil.register(Relation.class);
			
			BusinessSetIdMethod = Business.class.getDeclaredMethod("setId", long.class);
			BusinessSetIdMethod.setAccessible(true);
			BusinessIsModifiedMethod = Business.class.getDeclaredMethod("isModified");
			BusinessIsModifiedMethod.setAccessible(true);
			BusinessUpdateWriteTimestampMethod = Business.class.getDeclaredMethod("updateWriteTimestamp");
			BusinessUpdateWriteTimestampMethod.setAccessible(true);
			BusinessGetIdsMethod = Business.class.getDeclaredMethod("getIds");
			BusinessGetIdsMethod.setAccessible(true);
			BusinessSaveIdMethod = Business.class.getDeclaredMethod("saveId", String.class, long.class);
			BusinessSaveIdMethod.setAccessible(true);
			BusinessSaveVersionMethod = Business.class.getDeclaredMethod("saveVersion", String.class, long.class);
			BusinessSaveVersionMethod.setAccessible(true);
			BusinessMarkMethod = Business.class.getDeclaredMethod("mark");
			BusinessMarkMethod.setAccessible(true);
			BusinessIsContainedMethod = Business.class.getDeclaredMethod("isContained", Session.class);
			BusinessIsContainedMethod.setAccessible(true);
			BusinessIncrVersionMethod = Business.class.getDeclaredMethod("incrVersion", String.class);
			BusinessIncrVersionMethod.setAccessible(true);
			
//			SessionGetMethod = Session.class.getDeclaredMethod("get", Business.class);
//			SessionGetMethod.setAccessible(true);
			
			RelationGetIdSetMethod = Relation.class.getDeclaredMethod("getIdSet");
			RelationGetIdSetMethod.setAccessible(true);
			
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
